Ext.define('DutyList.calendar.data.MemoryGroupsStore', {
    extend: 'Ext.data.Store',
    model: 'DutyList.calendar.data.Groups',

    requires: [
        'Ext.data.proxy.Memory',
        'Ext.data.reader.Json',
        'Ext.data.writer.Json',
        'DutyList.calendar.data.Groups',
        'DutyList.calendar.data.User'
    ],

    /*constructor: function(config){
        this.groupField =  'name' ;
        this.sorters = this.sorters || [DutyList.calendar.data.Groups.name];
        this.callParent(arguments);
    },*/

    getGroups: function(requestGroupString) {
        var records = this.data.items,
            length = records.length,
            groups = [],
            pointers = {},
            record,
            groupStr,
            group,
            i;

        for (i = 0; i < length; i++) {
            record = records[i];
            groupStr = this.getGroupString(record);
            group = pointers[groupStr];

            if (group === undefined) {
                group = {
                    name: groupStr,
                    children: []
                };

                groups.push(group);
                pointers[groupStr] = group;
            }

            group.children.push(record);
        }
        groups.push({
            name: 'trololo',
            children: []
        });
        console.log(groups);
        return requestGroupString ? pointers[requestGroupString] : groups;
    }



});